package spacecraft;

import java.awt.Color;
import java.awt.FontMetrics;
import java.awt.Graphics2D;
import java.awt.Rectangle;

import markgame2d.engine.MarkScreen;


public class GameOverScreen extends MarkScreen{
	
	SpaceCraft game;
	
	long time;
	
	public GameOverScreen() {
		this.game = SpaceCraft.getInstance();
	}
	public void paint(Graphics2D g){
		g.setColor(Color.WHITE);
		FontMetrics metrics = g.getFontMetrics();
		Rectangle rect = metrics.getStringBounds("GAME OVER", g).getBounds();
		g.drawString("GAME OVER", game.getWidth()/2-rect.width/2, game.getHeight()/2-rect.height/2);
	}
	public void onEnter() {
		time = System.currentTimeMillis();
	}
	public void update(float time) {
		if(System.currentTimeMillis() - this.time > 2000){
			game.setScreen(game.beginScreen);
		}
	}
}